// pages/demo11/demo11.js
Page({

  onShow(){
    wx.bus.on("changeA", function(sum){console.log(sum+1)})
  },
  onUnload: function () {
    //页面卸载时触发。如wx.redirectTo或wx.navigateBack到其他页面时
    console.log("页面的生命周期onUnload")
    wx.bus.off("changeA", function(sum){console.log(sum+1)})
  },
  pageChangeA(data){

  },
  /**
   * 页面的初始数据
   */
  data: {
    numberA:0,
    list: [
      {
        id: 0,
        name: "模拟器",
        isActive: true
      },
      {
        id: 1,
        name: "编辑器",
        isActive: false
      },
      {
        id: 2,
        name: "调试器",
        isActive: false
      },
      {
        id: 3,
        name: "可视化",
        isActive: false
      },
    ]
  },
  onItemClick(e) {
    console.log("这里是父组件内的onItemClick事件", e)
    let { activeId } = e.detail;
    let { list } = this.data;
    list.forEach(item => item.isActive = item.id === activeId)
    this.setData({
      list
    })
  }
})